package com_2;
/*2.键盘录入多个数据,以0结束(输入0则停止录入) 要求在控制台输出这多个数据中的最大值.*/

import java.util.ArrayList;
import java.util.Scanner;

public class Tset4 {
    public static void main(String[] args) {//
        ArrayList<Integer> a = new ArrayList();//
        Scanner sc = new Scanner(System.in);//
        while (true) {//
            System.out.println("请输入一个随机数");//
            Integer number = sc.nextInt();//
            if (number != 0) {//
                a.add(number);//
            }
            if (number == 0) {//
                Integer b = a.get(0);//
                for (int i = 0; i < a.size(); i++) {//
                    if (a.get(i) > b) {//
                        b = a.get(i);//
                    }
                }
                System.out.println("最大值是："+b);//
            }
        }
    }
}
